package com.luanye.enjoy.utils;

import com.alibaba.fastjson.JSON;
import com.luanye.enjoy.config.SpringUtilConfig;
import com.luanye.enjoy.dto.SmsDTO;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import static com.luanye.enjoy.constants.MQConst.SMS_EXCHANGE;

public class SmsUtil {

    public static void sendSms(SmsDTO dto){
        RabbitTemplate rabbitTemplate = SpringUtilConfig.getBean(RabbitTemplate.class);

        rabbitTemplate.convertAndSend(SMS_EXCHANGE, "*", new Message(JSON.toJSONBytes(dto), new MessageProperties()));
    }
}
